package com.ustadzmenjawab.indexing;

import java.io.Reader;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.id.IndonesianAnalyzer;
import org.apache.lucene.analysis.synonym.SynonymFilter;
import org.apache.lucene.analysis.synonym.SynonymMap;
import org.apache.lucene.util.Version;

public class UstadzMenjawabSynAnalyzer extends Analyzer {
	private Version version;
	public UstadzMenjawabSynAnalyzer(Version version) {
		this.version = version;
	}

	@Override
	public TokenStream tokenStream(String arg0, Reader arg1) {
		Analyzer inaAnalyzer = new IndonesianAnalyzer(this.version);
		TokenStream tstream = inaAnalyzer.tokenStream(arg0, arg1);
		SynonymMap synonymMap = UstadzMenjawabSynonymMap.getInstance();
		SynonymFilter synFilter = new SynonymFilter(tstream,synonymMap, true);
		
		return synFilter;
	}

	

}
